const COS = require('cos-nodejs-sdk-v5');
const cos = new COS({
    SecretId: 'wx4abf7dc46f46fd7b',
    SecretKey: '38553c5e31f2fab93143fb7ef865e291',
});

// 上传文件到对象存储
exports.uploadFile = async (filePath) => {
    try {
        const result = await cos.putObject({
            Bucket: '7072-prod-5gduafzd5d123d73-1326429543',
            Region: 'ap-shanghai',
            Key: '/', // 上传到对象存储的路径
            StorageClass: 'STANDARD',
            Body: fs.createReadStream(filePath),
            onProgress: function (progressData) {
                console.log(JSON.stringify(progressData));
            },
        });
        console.log(result);
    } catch (err) {
        console.error(err);
    }
};
